package it.interazionemultimodale.twitterrecognizer.twitterutility;

import twitter4j.HashtagEntity;
import twitter4j.MediaEntity;
import twitter4j.Status;
import twitter4j.URLEntity;
import twitter4j.UserMentionEntity;
import android.graphics.Bitmap;

public class TweetInfo
{
	private Status status;
	private Bitmap bitmap;
	
	public TweetInfo(Status status, Bitmap bitmap)
	{
		this.status = status;
		this.bitmap = bitmap;
	}
	
	public Bitmap getBitmap()
	{
		return this.bitmap;
	}
	
	public long getStatusId()
	{
		return this.status.getId();
	}
	
	public String getStatusText()
	{
		return this.status.getText();
	}
	
	public boolean statusTextContainsMedia()
	{
		 return this.status.getMediaEntities().length > 0;
	}
	
	public boolean statusTextContainsURL()
	{
		return this.status.getURLEntities().length > 0;
	}
	
	public String getSimplifiedStatusText()
	{
		String text = this.getStatusText();
		
		for (MediaEntity m : this.status.getMediaEntities())
			text = text.replace(m.getURL(), "");
		
		for (URLEntity u : this.status.getURLEntities())
			text = text.replace(u.getURL(), "");
		
		for (HashtagEntity ht : this.status.getHashtagEntities())
		{
			String hashtag = ht.getText();
			text = text.replace("#" + hashtag, "tag " + hashtag);
		}
		
		for (UserMentionEntity um : this.status.getUserMentionEntities())
		{
			String userMention = um.getText();
			text = text.replace("@" + userMention, "at " + userMention);
		}
		
		return text;
	}
	
	public String getUsername()
	{
		return this.status.getUser().getName();
	}
	
	public String getScreenName()
	{
		return this.status.getUser().getScreenName();
	}
	
	public String getUserLang()
	{
		return this.status.getUser().getLang();
	}
}
